import { Component, Vue, Inject } from 'vue-property-decorator';

import { IUserFans } from '@/shared/model/user-fans.model';
import UserFansService from './user-fans.service';

@Component
export default class UserFansDetails extends Vue {
  @Inject('userFansService') private userFansService: () => UserFansService;
  public userFans: IUserFans = {};

  beforeRouteEnter(to, from, next) {
    next(vm => {
      if (to.params.userFansId) {
        vm.retrieveUserFans(to.params.userFansId);
      }
    });
  }

  public retrieveUserFans(userFansId) {
    this.userFansService()
      .find(userFansId)
      .then(res => {
        this.userFans = res;
      });
  }

  public previousState() {
    this.$router.go(-1);
  }
}
